<?php
//Khai bao namespace
namespace Product\Controller;

//Load lớp AbstractActionController vào CONTROLLER
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Mvc\Controller\Plugin\Params;
use Product\Form\ProductForm;       // <-- Add this import

//Load lớp ViewModel vào CONTROLLER
use Zend\View\Model\ViewModel;

class ProductController extends AbstractActionController
{
    public function init() {
        parent::init();
    }

    public function indexAction()
    {
//         // grab the paginator from the AlbumTable
//         $paginator = $this->getAlbumTable()->fetchAll(true);
//         // set the current page to what has been passed in query string, or to 1 if none set
//         $paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page', 1));
//         // set the number of items per page to 10
//         $paginator->setItemCountPerPage(10);

//         return new ViewModel(array(
//                 'paginator' => $paginator
//         ));
    }
    public function addAction()
    {
        $form = new ProductForm();

        $request = $this->getRequest();
        if ($request->isPost()) {

            var_dump($request->getPost()->toArray()); die;
//            $files =  $request->getFiles()->toArray();
//            $fileName = $files['image-file']['name'];

//            $uploadObj = new \Zend\File\Transfer\Adapter\Http();
//            $uploadObj->setDestination(FILES_PATH);

//            $result = $uploadObj->receive($fileName);

//            die(json_encode(array('result'=>$result, 'filename'=>$fileName)));
       }

       $view = new ViewModel(array('form'=>$form));

       return $view;
    }
}